package defaultPackage;

import java.awt.*;

public class Tile
{
	double oxygen = 0;
	int x,y,scale = 10;
	public tileType type = tileType.Space;
	static boolean showOxygen = false;
	boolean occupied = false,hasPerson = false,jobHere = false,hasAirlock;
	public static void setOxygenDebug(boolean arg)
	{
		showOxygen = arg;
	}
	public static boolean getOxygenDebug()
	{
		return showOxygen;
	}
	public Tile (int x, int y,tileType type, int oxygen, boolean occupied)
	{
		this.x = x * scale;
		this.y = y * scale;
		this.oxygen = oxygen;
		settype(type);
		
		
	}
	
	public void draw (Graphics g)
	{
		{
			g.setColor(type.getColor());
			g.fillRect(x, y, 10, 10);
			//g.setColor(Color.red);
			//g.drawRect(x, y, 10, 10);
			if (type == tileType.Interior)
			{
				g.setColor(Color.LIGHT_GRAY);
				g.drawRect(x, y, 9, 9);
			}
			if (showOxygen && !type.getSolid())
			{
				int stringy = y + 10;
				//if (oxygen > 0) 
				{
					//g.setColor(Color.red);
					//g.fillRect(x, y, 10, 10);
				}
				g.setColor(Color.gray);
				g.drawString("" + getRoundedOxygen()%10, x, stringy);
			}
		}
	}

	public void settype(tileType type)
	{
			Resources.setResources(Resources.getResources() -  type.getVal() + this.type.getVal());
			this.type = type;
	}
	public void changeType(tileType type)
	{
		this.type = type;
	}
	public tileType getType()
	{
		return type;
	}
	public void setOxygen(double oxygen)
	{
		this.oxygen = oxygen;
	}
	public void addOxygen(double oxygen)
	{
		if(this.oxygen+oxygen<100)
		{
			this.oxygen+=oxygen;
		}else
		{
			this.oxygen=100;
		}
	}
	public void changeOxygen(double change)
	{
		oxygen+=change;
	}
	public double getOxygen()
	{
		return oxygen;
	}
	public int getRoundedOxygen()
	{
		return ((int)(oxygen + .5));
	}
	public boolean isOccupied()
	{
		return occupied;
	}
	public void setOccupied(boolean occupied)
	{
		this.occupied = occupied;
	}
	
	public boolean hasPerson()
	{
		return hasPerson;
	}
	public boolean hasJobHere()
	{
		return jobHere;
	}
	public void setJobHere(boolean jobHere)
	{
		this.jobHere = jobHere;
	}
	
	public boolean hasAirlock()
	{
		return hasAirlock;
	}
	
	public void setHasAirlock(boolean hasAirlock)
	{
		this.hasAirlock = hasAirlock;
	}
}
